package com.example.lgseckill.controller;

import com.example.lgseckill.domain.UserSeckillOrderInfoVO;
import com.example.lgseckill.service.ISeckillOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Author:e
 * Date:2021/8/17 10:30 上午
 **/
@Controller
@RequestMapping("/seckill/order")
public class SeckillOrderController {

    @Autowired
    private ISeckillOrderService seckillOrderService;

    @GetMapping()
    public List<UserSeckillOrderInfoVO> seckillOrderList(){
        return seckillOrderService.seckillOrderList();
    }

    @GetMapping("/now/{userId}")
    public String seckillOrderNow(ModelMap map,@PathVariable("userId") Long userId){
        List<UserSeckillOrderInfoVO> seckillOrderInfos =
                seckillOrderService.findSeckillOrderNowByUserId(userId);
        map.addAttribute("seckillOrderInfos",seckillOrderInfos);
        map.addAttribute("suerId",userId);
        return "order_list";
    }
}
